package com.huaxin.common.view.avatarimageview;

import android.content.Context;
import android.os.Bundle;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.squareup.haha.perflib.Instance;

/**
 * Created by songxf on 2017/8/4.
 * 设置用户头像头像
 */

public class HxAvatarImageGlide {
    private Context mContext;


    private static HxAvatarImageGlide mInstance = null;

    private HxAvatarImageGlide() {
    }

    public static HxAvatarImageGlide getInstance() {
        if (mInstance == null) {
            synchronized (HxAvatarImageGlide.class) {
                mInstance = new HxAvatarImageGlide();
            }
        }
        return mInstance;
    }

    public void setHeadImage(Context context, String url, String userName, AvatarImageView view) {
        mContext = context;
        view.setTextAndColorSeed(userName, userName);
        Glide.with(context).load(url).apply(new RequestOptions().centerCrop()).into(view);
        //Glide.with(context).load(url).centerCrop().crossFade().into(view);
    }

}
